import Vue from 'vue'
import VueRouter from 'vue-router'
import home from '../pages/home'
import index from '../pages/index'
import product from '../pages/product'
import detail from '../pages/detail'
import cart from '../pages/cart'
import order from '../pages/order'
import orderConfirm from '../pages/orderConfirm'
import orderList from '../pages/orderList'
import orderPay from '../pages/orderPay'
import aliPay from '../pages/alipay'
import login from '../pages/login'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: "home",
    component: home,
    redirect:'/index',
    children: [{
        path: 'index',
        name: "index",
        component: index,
      },
      {
        path: 'product/:id',
        name: "product",
        component: product,
      },
      {
        path: 'detail/:id',
        name: "detail",
        component: detail,
      },
    ]
  },
  {
    path: "/cart",
    name: "cart",
    component: cart
  },
  {
    path: "/order",
    name: "order",
    component: order,
		redirect:'/order/list',
    children: [{
        path: 'confirm',
        name: "order-confirm",
        component: orderConfirm,
      },
      {
        path: 'list',
        name: "order-list",
        component: orderList,
      },
      {
        path: 'pay',
        name: "order-pay",
        component: orderPay,
      },
      {
        path: 'aliPay',
        name: "ali-pay",
        component: aliPay,
      },
    ]
  },
  {
    path: '/login',
    name: "login",
    component: login,
  }
]

const router = new VueRouter({
  routes
})

export default router